<template>
  <div class="app-container">
    <!-- 表单查询 -->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="奖品等级">
        <el-select v-model="searchObj.prizelevel" placeholder="请选择奖品等级">
          <el-option label="全部" value="0"></el-option>
          <el-option label="一等奖" value="1"></el-option>
          <el-option label="二等奖" value="2"></el-option>
          <el-option label="三等奖" value="3"></el-option>
          <el-option label="四等奖" value="4"></el-option>
          <el-option label="五等奖" value="5"></el-option>
          <el-option label="六等奖" value="6"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="兑换状态">
        <el-select v-model="searchObj.encashstate" placeholder="请选择兑换状态">
          <el-option label="全部" value="0"></el-option>
          <el-option label="未兑" value="10"></el-option>
          <el-option label="已兑" value="00"></el-option>
        </el-select>
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
    </el-form>

    <!-- banner列表 -->
    <el-table :data="list" stripe style="width: 100%">
      <el-table-column type="index" width="50"/>
      <el-table-column prop="subscrbid" label="用户编号"/>
      <el-table-column prop="areaid" label="地区编码"/>
      <el-table-column prop="svcid" label="业务类型"/>
      <el-table-column prop="cardno" label="卡序列号"/>
      <el-table-column prop="prizelevel" label="奖品等级（1-6）"/>
      <el-table-column prop="giftcode" label="礼品编码"/>
      <el-table-column prop="optrid" label="操作员"/>
      <el-table-column prop="acptsiteid" label="受理点"/>
      <el-table-column prop="optrdate" label="操作时间"/>
      <el-table-column prop="transn" label="流水号"/>
      <el-table-column prop="remarks" label="备注"/>
      <el-table-column label="兑换状态" width="80">
        <template slot-scope="scope">
          {{ scope.row.encashstate === '10' ? '可用' : '不可用' }}
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination
        :current-page="current"
        :page-size="limit"
        :total="total"
        style="padding: 30px 0; text-align: center;"
        layout="total, prev, pager, next, jumper"
        @current-change="getList"
    />

  </div>
</template>
<script>
//引入api接口
import hospitalSetApi from "@/api/ggk";

export default {
  // 定义数据模型
  data() {
    return {
      current: 1,
      limit: 3,
      searchObj: {},
      list: [], // 列表
      total: 0
    }
  },
  // 页面渲染成功后获取数据
  created() {
    this.getList();
  },

  methods: {//定义方法对api接口的方法调用
    //医院设置列表
    getList(page = 1) {
      this.current = page
      hospitalSetApi.getggkList(this.current, this.limit, this.searchObj)
          .then(res => {
            this.current=this.page.current
            this.list = res.data.records
            this.total = res.data.total
            console.log(res)
          })//请求成功
          .catch(error => {
            console.log(error)
          })//请求失败
    }
  }
};
</script>
